package com.cpi.cornpp.unit.service;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.unit.dao.UnitDAO;
import com.cpi.cornpp.unit.dto.UnitDTO;
import com.cpi.cornpp.unit.exception.UnitException;

public class UnitService {
	public double getUnitQuantity(String unitId)throws UnitException{
		UnitDAO unitDAO = null;
		UnitDTO unitDTO = null;
		double quantity = 0;
		try {
			unitDAO = new UnitDAO();
			unitDTO = unitDAO.getUnit(unitId);
			quantity = unitDTO.getQuantity();
		} catch (UnitException unitException) {			
			throw unitException;
		}catch (Exception exception){
			UnitException unitException = null;
			exception.printStackTrace(System.out);
			unitException= new UnitException(exception , CornPPException.LAYER_SERVICE,CornPPException.ACTION_LISTS);
			throw unitException;
		}
		return quantity;
	}
}